package com.scgk.sync.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;


/**
 * swagger2配置类
 * @author wusong
 * 注意：此配置类，一定要被扫描到，否则访问不了Knife4j接口文档
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean
    public Docket adminApiConfig(){
        Docket adminApi = new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select()
                //只显示com.scgk路径下的页面
                .apis(RequestHandlerSelectors.basePackage("com.scgk"))
                .paths(PathSelectors.any())
                .build();
        return adminApi;
    }

    private ApiInfo adminApiInfo(){

        return new ApiInfoBuilder()
                .title("cloud-API文档")
                .description("本文档描述了cloud微服务接口定义")
                .version("1.0")
                .build();
    }

}